package com.cloudloan.common;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 全局异常处理类
 */
@ControllerAdvice(annotations = {RestController.class, Controller.class})//只要类上加了这两个处理器的就会被拦截
@ResponseBody
public class HandleOtherExceptions {
    @ExceptionHandler({RuntimeException.class})
    public R runtimeException(RuntimeException ex) {
        String message = "请联系管理员处理错误信息:"+ex.getMessage();
        return R.error(message);
    }
}
